{assign $pathImageEntreprise = ENTREPRISE_PATH_PHOTO}
{assign $checked="checked='checked'"}

<div id="main_container">

    {$oZoneHeader}

    <div class="main_content">
        {$oZoneTopMenu}
        <div class="center_content">  
            <div class="left_content"> 
                {$oZoneLeftMenu}
                <h3>{$typeEntreprise->type_name}</h3> 
                {if sizeof($departementParTypeEntreprise)}
                <table style="width:240px" id="rounded-corner" summary="2007 Major IT Companies' Profit">
                       {foreach $departementParTypeEntreprise as $departement_num}
                       {if $departement_num != NULL && $departement_num != " "}
                        <tr>
                            <td>
								<strong>{$departement_num}</strong>
							</td>
						</tr>
						<tr>
							<td>
								<table>
                                {if sizeof ($entrepriseByType)}
								{foreach $entrepriseByType as $item}
									{if (($item->departement_num .' '. $item->departement_nom) == $departement_num) }
										<tr>
											<td>
												<a href="{jurl 'entreprise~BoEntreprise:index', array('id'=>$item->entreprise_id)}">{$item->entreprise_name}</a>
											</td>
										</tr>
									{/if}
								{/foreach}
                                {/if}
								</table>
                            </td>
                        </tr>
                        {/if}
                        {/foreach}
                </table>
                {/if}
            </div>
    
            <div class="right_content">
                {if $id}
                    <h2>Editer une entreprise</h2> 
                    {assign $disabled = "DISABLED"}
                {else}
                    <h2>Ajouter une entreprise</h2> 
                    {assign $disabled = ""}

                {/if} 
                    
                <form action="{jurl 'entreprise~BoEntreprise:sauvegarder'}" method="post" id="editEntreprise" name="editEntreprise" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="{$entreprise->entreprise_id}" />
                   <dl>
                        <dt><label>Type : </label></dt>
                        <dd>
                            <select name="type" validation="required">
							     <option value="">Sélectionner un type</option>
                                    {foreach $type as $typeItem}
                                        {if ($typeItem->type_id == $entreprise->entreprise_type_id)} 
                                              {assign $selected='selected="selected"'}
                                         {else}
                                              {assign $selected=''}
                                        {/if}
                                       <option value="{$typeItem->type_id} " {$selected} >{$typeItem->type_name}</option>
                                    {/foreach}
                            </select>
                        </dd>
                    </dl>
                    <dl>
                        <dt><label>Société : </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_name}" name="societe"  validation="required"/></dd>
                    </dl>
                    <dl style="height:auto">
                        <dt><label>Description : </label></dt>
                        <dd style="width:600px;">
                            <textarea id="content" name="content"  validation="required" > {$entreprise->entreprise_description}</textarea>
                            <script type="text/javascript">
                                {literal}CKEDITOR.replace( 'content', {width:'600px', toolbar:'AOToolbar'}) ;{/literal}
                            </script>
                        </dd>
                    </dl>
                    <dl style="height:auto">
                        <dt><label>Adresse : </label></dt>
                        <dd><textarea id="adresse" name="adresse"  validation="required" style="width:191px;"> {$entreprise->entreprise_adresse}</textarea></dd>
                    </dl>
                    <dl>
                        <dt><label>Code Postal : </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_cp}" name="cp"  validation="required"/></dd>
                    </dl>
                    <dl>
                        <dt><label>Ville : </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_ville}" name="ville"  validation="required"/></dd>
                    </dl>
                    <dl>
                        <dt><label>Département : </label></dt>
                        <dd>
                            <select name="departement" validation="required">
                                <option value="">Sélectionner un département</option>
                                {foreach $departement as $departementItem}
                                    {if ($departementItem->departement_id == $entreprise->entreprise_departement)} 
                                          {assign $selected='selected="selected"'}
                                    {else}
                                          {assign $selected=''}
                                    {/if}
                                    <option value="{$departementItem->departement_id}" {$selected}>{$departementItem->departement_nom}</option>
                                {/foreach}
                            </select>
                        </dd>
                     </dl>
                     </dl>

                     <dl>
                        <dt><label>Téléphone : </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_tel}" name="tel"  validation="required" /></dd>
                     </dl>

                     <dl>
                        <dt><label>Téléphone 2 : </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_tel2}" name="tel2"  /></dd>
                     </dl>

                     <dl>
                        <dt><label>Fax: </label></dt>
                        <dd><input type="text"  value="{$entreprise->entreprise_fax}" name="fax"  /></dd>
                     </dl>

                      <dl>
                        <dt><label>Email : </label></dt>
                          <dd><input type="text"  value="{$entreprise->entreprise_email}" name="email" /></dd>
                      </dl>
                      <dl>
                        <dt><label>Site Web : </label></dt>
                          <dd><input type="text"  value="{$entreprise->entreprise_site}" name="site" /></dd>
                      </dl>
                      <dl style="height:23px">
                        <dt><label>Logo : </label></dt>
                          <dd><input type="file" name="logo" value="{$entreprise->entreprise_logo}"  /></dd>
                      </dl>
                      {if $entreprise->entreprise_id && $entreprise->entreprise_logo}
                            <img src="{$pathImageEntreprise}{$entreprise->entreprise_logo}" alt="{$entreprise->entreprise_name}" width="90" height="60" style="margin-left:155px;"/>
                      {/if}
                    <dl style="height:45px;">
                        <dt style="line-height:20px;"><label>Piéces d'occasion pour les particuliers ? : </label></dt>
                          <dd><input type="checkbox" name="entreprise_piece" value="1"  {if $entreprise->entreprise_piece == 1}checked{/if} /></dd>
                      </dl>
                    <dl style="height:51px;">
                        <dt style="line-height:20px;"><label>Jours et horaires <br />d'ouvertures : </label></dt>
                          <dd><textarea name="entreprise_ouverture" style="width:191px;">{$entreprise->entreprise_ouverture}</textarea></dd>
                      </dl>
                     <dl class="submit">
                        <input  id ="valider-annonce" class="valider" title="Valider" type="submit" value="" style="margin-right:10px;"/>
                        <a title="Annuler" href="{jurl 'entreprise~BoEntreprise:index'}" class="bt_green"><span class="bt_green_lft"></span><strong>Annuler</strong><span class="bt_green_r"></span></a>

                     </dl>
                 </form>

            </div><!-- end of right content-->
        </div>   <!--end of center content -->               

        <div class="clear"></div>
    </div> <!--end of main content-->
    
    
    <div class="footer">
    </div>

</div>

 {literal} 
         <style  type="text/css">

                .error input {border:1px solid red !important;}
                .error textarea {border:1px solid red !important;}
                .errorlist li {font-size: 0.8em;}

                td.bleu-tab-liste {background-color:#99CCFF !important;}
                td.jaune-tab-liste{background-color:#FFFF99 !important;}
                td.rouge-tab-liste{background-color:#C92828 !important;}
                td .paire-tab-liste { background-color:#CCCCCC !important; }
                td a {color:#7C7777 !important;}
          </style>

          <script type="text/javascript">
                $(function(){
                    $( "#datepicker" ).datepicker({dateFormat: 'dd/mm/yy'});
                    $( "#datepicker2" ).datepicker({dateFormat: 'dd/mm/yy'});
                    $( "#datepicker3" ).datepicker({dateFormat: 'dd/mm/yy'});

                // form validation
                var test = $("#editEntreprise");
                test.validation();
                test.submit(function(e) {
                    $("#valid-form").remove();
                    if(test.validate()) {
                        document.forms["editEntreprise"].submit();
                    }
                    e.preventDefault();
                });

              });
          </script>

  {/literal}